<?php

function curl_get_file_contents($url)
{
	$c = curl_init();
	curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($c, CURLOPT_ENCODING, 'UTF-8');
	curl_setopt($c, CURLOPT_URL, $url);
	$contents = curl_exec($c);
	curl_close($c);

	if ($contents) return $contents;
	else return FALSE;
}

function convert_vi_to_en($str) {
	$str = preg_replace("/(ÃƒÂ |ÃƒÂ¡|Ã¡ÂºÂ¡|Ã¡ÂºÂ£|ÃƒÂ£|ÃƒÂ¢|Ã¡ÂºÂ§|Ã¡ÂºÂ¥|Ã¡ÂºÂ­|Ã¡ÂºÂ©|Ã¡ÂºÂ«|Ã„Æ’|Ã¡ÂºÂ±|Ã¡ÂºÂ¯|Ã¡ÂºÂ·|Ã¡ÂºÂ³|Ã¡ÂºÂµ)/", 'a', $str);
	$str = preg_replace("/(ÃƒÂ¨|ÃƒÂ©|Ã¡ÂºÂ¹|Ã¡ÂºÂ»|Ã¡ÂºÂ½|ÃƒÂª|Ã¡Â»ï¿½|Ã¡ÂºÂ¿|Ã¡Â»â€¡|Ã¡Â»Æ’|Ã¡Â»â€¦)/", 'e', $str);
	$str = preg_replace("/(ÃƒÂ¬|ÃƒÂ­|Ã¡Â»â€¹|Ã¡Â»â€°|Ã„Â©)/", 'i', $str);
	$str = preg_replace("/(ÃƒÂ²|ÃƒÂ³|Ã¡Â»ï¿½|Ã¡Â»ï¿½|ÃƒÂµ|ÃƒÂ´|Ã¡Â»â€œ|Ã¡Â»â€˜|Ã¡Â»â„¢|Ã¡Â»â€¢|Ã¡Â»â€”|Ã†Â¡|Ã¡Â»ï¿½|Ã¡Â»â€º|Ã¡Â»Â£|Ã¡Â»Å¸|Ã¡Â»Â¡)/", 'o', $str);
	$str = preg_replace("/(ÃƒÂ¹|ÃƒÂº|Ã¡Â»Â¥|Ã¡Â»Â§|Ã…Â©|Ã†Â°|Ã¡Â»Â«|Ã¡Â»Â©|Ã¡Â»Â±|Ã¡Â»Â­|Ã¡Â»Â¯)/", 'u', $str);
	$str = preg_replace("/(Ã¡Â»Â³|ÃƒÂ½|Ã¡Â»Âµ|Ã¡Â»Â·|Ã¡Â»Â¹)/", 'y', $str);
	$str = preg_replace("/(Ã„â€˜)/", 'd', $str);
	$str = preg_replace("/(Ãƒâ‚¬|Ãƒï¿½|Ã¡ÂºÂ |Ã¡ÂºÂ¢|ÃƒÆ’|Ãƒâ€š|Ã¡ÂºÂ¦|Ã¡ÂºÂ¤|Ã¡ÂºÂ¬|Ã¡ÂºÂ¨|Ã¡ÂºÂª|Ã„â€š|Ã¡ÂºÂ°|Ã¡ÂºÂ®|Ã¡ÂºÂ¶|Ã¡ÂºÂ²|Ã¡ÂºÂ´)/", 'A', $str);
	$str = preg_replace("/(ÃƒË†|Ãƒâ€°|Ã¡ÂºÂ¸|Ã¡ÂºÂº|Ã¡ÂºÂ¼|ÃƒÅ |Ã¡Â»â‚¬|Ã¡ÂºÂ¾|Ã¡Â»â€ |Ã¡Â»â€š|Ã¡Â»â€ž)/", 'E', $str);
	$str = preg_replace("/(ÃƒÅ’|Ãƒï¿½|Ã¡Â»Å |Ã¡Â»Ë†|Ã„Â¨)/", 'I', $str);
	$str = preg_replace("/(Ãƒâ€™|Ãƒâ€œ|Ã¡Â»Å’|Ã¡Â»Å½|Ãƒâ€¢|Ãƒâ€�|Ã¡Â»â€™|Ã¡Â»ï¿½|Ã¡Â»Ëœ|Ã¡Â»â€�|Ã¡Â»â€“|Ã†Â |Ã¡Â»Å“|Ã¡Â»Å¡|Ã¡Â»Â¢|Ã¡Â»Å¾|Ã¡Â»Â )/", 'O', $str);
	$str = preg_replace("/(Ãƒâ„¢|ÃƒÅ¡|Ã¡Â»Â¤|Ã¡Â»Â¦|Ã…Â¨|Ã†Â¯|Ã¡Â»Âª|Ã¡Â»Â¨|Ã¡Â»Â°|Ã¡Â»Â¬|Ã¡Â»Â®)/", 'U', $str);
	$str = preg_replace("/(Ã¡Â»Â²|Ãƒï¿½|Ã¡Â»Â´|Ã¡Â»Â¶|Ã¡Â»Â¸)/", 'Y', $str);
	$str = preg_replace("/(Ã„ï¿½)/", 'D', $str);
	//$str = str_replace(" ", "-", str_replace("&*#39;","",$str));
	return $str;
}

function nomalizeDate($open_date)
{
	$dateObj = date_create_from_format('d-m-Y', trim($open_date));
	return date_format($dateObj, 'Y-m-d');
}


function equal_result($result1, $result2)
{

	if($result1['open_date']!==$result2['open_date'])
	{
		return false;
	}
	$array1= $result1['detail'];
	$array2=$result2['detail'];

	if(sizeof($array1) !== sizeof($array1)){
		return false;
	}
	 
	$size = sizeof($array1);
	 
	for($i=0;$i<$size;$i++){
		if(!in_array($array1[$i],$array2)){
			return false;
		}
	}
	 
	return true;
}
?>